<?php

/**
 * Created by JetBrains PhpStorm.
 * User: jh
 * Date: 12-10-1
 * Time: 下午6:16
 * To change this template use File | Settings | File Templates.
 */
class Setup_Autoload extends Setup_Abstract implements Setup_Interface
{

    public function setup()
    {
        ServiceLocator::attachLocator(new FileLocator(Config::get('app.module_path')), 'File');

        ServiceLocator::attachLocator(new FileLocator(Config::get('app.library_path')), 'Library');
        
        ServiceLocator::attachLocator(new FileLocator(Config::get('app.third_party_path')), 'ThirdParty');

        ServiceLocator::attachLocator(new FlourishLocator(), 'Flourish');

        set_include_path(get_include_path() . PATH_SEPARATOR . Config::get('app.third_party_path'));
        
        require_once 'spoon/spoon.php';
		
		$dbInstance = Database_ConnectionFactory::getFactory()->getConnection('mysql', 
                                                                            Config::get('db.host'), 
                                                                            Config::get('db.username'),  
                                                                            Config::get('db.password'),
                                                                            Config::get('db.database'));
																			
		Config::set('mysql', $dbInstance);
		
    }

}
